home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / lollipop / list.tex < prev    next >
Text File  |  1993-01-28  |  16KB  |  425 lines

  1. % List.tex copyright 1992 Victor Eijkhout
  2. \Chapter Lists
  3.  
  4. Lists in Lollipop are defined by \refcs{DefineList}:
  5.  
  6. \Ver>\DefineList:Foo [...]
  7.     item:start [...] item:stop
  8.     [...] Stop<Rev
  9. and the resulting list is used as
  10. \Ver>\Foo
  11. \item [ ..text.. ]
  12. \item [ ... ]
  13. \FooStop<Rev
  14. where the closing command can be abbreviated as~\cs{>}.
  15.  
  16. \Section Label alignment
  17.  
  18. In general there is a default position for labels; 
  19. either aligning with the
  20. left or the right side of the margin over which the list is indented.
  21. The two ways are indicated with the option \refopt{item}:
  22. \Ver>    item:left [...] item:stop<Rev
  23. and \Ver>    item:right [...] item:stop<Rev respectively.
  24. Specifying \opt{item:start} gives the default left aligning position.
  25.  
  26. \Example
  27. \DefineList:enumerate
  28.     item:start itemCounter ) item:stop Stop
  29. \DefineList:enumerateright
  30.     item:right ( itemCounter ) Spaces:1 item:stop Stop
  31. \enumerate\item Some item
  32. \item And another
  33. \enumerateright\item First nested item
  34. \item Next nested item\>
  35. \item And back to the original list.\>
  36. \ExampleStop
  37.  
  38. \Section List indentation
  39.  
  40. The amount over which the text of a list (excluding the item labels)
  41. is indented is controled by a list of indentations. This is explained
  42. in section~\ref[sec:indent:control]. The indentation amount is most of
  43. the time also equal to the value of the paragraph indentation outside
  44. that list.
  45.  
  46. In the rare case where the indentation of a list has to be controlled
  47. explicitly, there is an option \refopt{indentation} with one value.
  48. \Ver>\DefineList:SomeList indentation=30pt [...] Stop<Rev
  49.  
  50.  
  51. \Section Label style
  52.  
  53. Every list that uses the \refopt{itemsign} option is an `itemize' list,
  54. no matter what it's name, and there is a counter in Lollipop that
  55. keeps track of how deep you are in itemize lists. Similarly, every
  56. list that uses \refopt{itemCounter} is an `enumerate' lists, and these
  57. are counted too.
  58.  
  59. On every next level a new style of item sign or counter is used. For
  60. item signs this is in sequence: $\bullet$, $\circ$, --, and $\cdot$
  61. for all higher levels. The style of sign can be changed by
  62. \refcs{SetItemSign}: \Ver>\SetItemSign:6=m<Rev where the letter
  63. indicating the sign is interpreted as: \n b~$\bullet$ (bullet), \n
  64. c~$\circ$ (circle), \n d~$\diamond$ (diamond), \n m~--- (em-dash), \n
  65. n~-- (en-dash), \n .~$\cdot$.
  66.  
  67. Similarly, the counter style can be set by
  68. \refcs{SetItemCounterRepresentation}:
  69. \Ver>\SetItemCounterRepresentation:2=i<Rev where the letter
  70. representing the style is interpreted as: 1~Arabic, I~uppercase roman,
  71. i~lowercase roman, A~uppercase characters, a~lowercase characters.
  72.  
  73. \Section Label width
  74.  
  75. The default width for a label is at most the width of the margin over
  76. which the list is indented. Using \opt{item:left} or \opt{item:right}
  77. will have the label pushed to the left or right side of this margin
  78. respectively. Now what if the label material is wider than this
  79. margin? Usually you want the label then to expand to the right, and
  80. that is indeed what happens, unless you specify
  81. \refopt{labeloverflow} with value \n{left}, in which case the right
  82. boundary of the label will not budge, and the label will start
  83. protruding into the outer margin.
  84.  
  85. \Section[sec:description:list] Description lists
  86.  
  87. A common type of list is the type where each item label consists of a
  88. piece of text. Such a list is called a `description' list in
  89. \Lollipop, and it recognized by the occurrence of the option
  90. \refopt{description} in its definition. A~description list can also use
  91. the item sign or the item counter, of course.
  92.  
  93. Using a description list, the description text is everything that
  94. follows the command \cs{item}, up to the end of the line.
  95.  
  96. \Example
  97. \DefineList:TestList 
  98.  item:left Style:bold itemCounter . Spaces:1 description
  99.       Spaces:2 item:stop Stop
  100. \TestList\item Do
  101. A deer, a female deer.\item Re
  102. According to mr. Fowler only a legal term.
  103. \item Mimi Jett
  104. The owner/founder of ETP\>
  105. \ExampleStop
  106.  
  107. As you can see, the problem of label overflow can easily occur with
  108. description lists. Thus it is a good idea to end the item material
  109. with some white space, as in the above example.
  110.  
  111.  Exceptional situation:
  112. if you use an empty description text, you should write \ver>\item{}>.
  113.  
  114. \Section Suspended lists
  115.  
  116. Occasionally the is a need to resume an enumerate list, that is,
  117. after a piece of text that is not part of the list an enumerate list
  118. should start counting from the previous value on. In \Lollipop\ this
  119. phenomenon can be realized by never ending the enumerate list, and
  120. simply moving the text one indentation level back with
  121. \refcs{PopIndentLevel}.
  122.  
  123. \Example
  124. \DefineList:enumerate item:left itemCounter item:stop Stop
  125. \enumerate\item First some item\par
  126. {\PopIndentLevel \Indent:no
  127. This text seems to be outside the list. Don't you believe it.\par}
  128. \item And another item\>
  129. \ExampleStop
  130.  
  131. Note that the `popped' text has to be in a group (otherwise the
  132. subsequent items will also be popped back), and it has to be
  133. separated from the preceding and following text by \cs{par}; the
  134. trailing \cs{par} has to be in the group.
  135.  
  136. \Section Item counter manipulation
  137.  
  138. The item counter can be manipulated explicitly. This is necessary for
  139. instance for starting a list at another value than one. What you need
  140. to realize here is that the command \cs{item} starts by incrementing
  141. the counter. Furthermore, the only way to access the item counter is
  142. through the commands for counters; see section~\ref[sec:counters].
  143.  
  144. \Example
  145. \DefineList:enumerate item:left itemCounter item:stop Stop
  146. \enumerate \SetCounter:item=-1
  147. \item Escape: usually the backslash.
  148. \item Begin Group.\>
  149. \ExampleStop
  150.  
  151. \Section List titles and list tails
  152.  
  153. Lists can have titles. The title follows the command that invokes the
  154. list, in the usual manner. Material to follow the list can also be
  155. specified: anything following the option \refopt{text} is considered to
  156. be trailing material.
  157.  
  158. \Example
  159. \DefineList:TestList hrule line:start Style:bold title line:stop
  160.  item:left Style:italic itemCounter item:stop
  161.  text vwhite:3pt hrule Stop
  162. \TestList In the last fiscal year, have you:\par
  163. \item Eaten peanuts? \item Walked the dog?
  164. \item Bought a Frank Zappa record?\>
  165. \ExampleStop
  166.  
  167. In case you wonder what happens with textual material after
  168. \opt{item:stop} and before any \opt{text}, well, that is taken to be
  169. inserted immediately after each item label.
  170.  
  171. \Section Between the items
  172.  
  173. There are special list options controlling what happens in between
  174. items. \Lollipop\ has an option \refopt{breakbetween}, analogous to
  175. \opt{breakbefore} and \opt{breakafter}; see
  176. section~\ref[sec:opt:penalties]. This item be default has a
  177. value of~\n{$-50$}, implying that breaks in between items
  178. should be preferred slightly over breaks in between the
  179. lines of an item.
  180.  
  181. Similarly, there is an option \refopt{whitebetween}
  182. controlling the amount of white space in between items that is
  183. analogous to \opt{whitebefore} and \opt{whiteafter}. Like these two
  184. options, it can also be set by the \cs{Distance} command
  185. (section~\ref[sec:com:distance]).
  186.  
  187. \Section Indentation in lists
  188.  
  189. An item can be considered to be consisting of at least one paragraph.
  190. That paragraph is never indented. For the behaviour of any next
  191. paragraph within the same item, the option \refopt{indentinside} can be
  192. used. This option has values yes/no. In case paragraphs inside an
  193. item indent, the indentation amount is level-controlled; see
  194. section~\ref[sec:indent:control].
  195.  
  196. \Chapter[chap:text:block] Text Blocks
  197.  
  198. The `text block' is a way of treating a moderate sized chunk of text
  199. in a different  way from the surrounding text. Text blocks are
  200. created by \refcs{DefineTextBlock}. Here is a small example.
  201.  
  202. \Example
  203. \DefineTextBlock:Quote 
  204.  PushIndentLevel PointSize:9 SetFont text Stop
  205. \Indent:no In some context it has been written that
  206. \Quote No man is an island.\QuoteStop
  207. In another:
  208. \Quote Run don't walk to the nearest island.\>
  209. Sometimes one would wish women weren't so logical.
  210. \ExampleStop
  211.  
  212. Note that the text block has an explicit closing command,
  213. consisting of the name of the block followed by \opt{Stop},
  214. and that implicit closing by \cs{>} is possible.
  215.  
  216. \Section The \opt{text} option
  217.  
  218. Text blocks have only one specific option: \refopt{text}. This option
  219. is used to separate material heading the block from material trailing
  220. the block. Example:
  221.  
  222. \Example
  223. \DefineTextBlock:DisplayEq 
  224.  whitebefore:abovedisplayskip whiteafter:belowdisplayskip
  225.  line:start white:parindent $ displaystyle text $ line:stop Stop
  226. The formula
  227. \DisplayEq e^{\pi i}+1=0\>
  228. contains nature's five most interesting constants.
  229. \ExampleStop
  230.  
  231. Here one dollar comes before the text, and one after, so the first is
  232. inserted by \cs{DisplayEq} and the second by the corresponding
  233. closing command.
  234.  
  235. Material before and after the text should usually not be broken.
  236. Hence \cs{nobreak} is automatically inserted. See the \cs{Example}
  237. macro for this manual: pages should not be broken after rules, or
  238. around the text `example~xyz'.
  239.  
  240. \Section More examples
  241.  
  242. A text block can encompass more than one paragraph, so the options
  243. \opt{indentinside} and \opt{indentfirst} are particularly useful here.
  244.  
  245. \Example
  246. \AlwaysIndent:no
  247. \DefineTextBlock:TestBlock PushIndentLevel
  248.  indentafter:yes indentfirst:no indentinside:yes 
  249.  text unskip hfill $ bullet $ par Stop
  250. One paragraph.\par The next paragraph
  251. \TestBlock Inside the block one paragraph.\par
  252. Inside the block the next paragraph.\>
  253. Outside the following paragraph.\par And the last paragraph.
  254. \ExampleStop
  255.  
  256. \ImpNote 
  257. \iSection[imp:gen:open:close] The environment in generic constructs
  258.  
  259. The text block is just about the purest use of the \Lollipop\
  260. environment mechanism. Here is how a text block is defined:
  261. \Ver>
  262. \def\@DefineTextBlock{
  263.     \csarg\edef{\@name}{\@gen@open
  264.         \the\before@coms
  265.         }
  266.     \@DefineStopCommand{\the\after@coms \@gen@close}
  267.     }<Rev
  268.  
  269. The \cs{before@coms} and \cs{after@coms} are two token lists with
  270. the heading and trailing commands.
  271.  
  272. It is important to note that the definition of the control sequence
  273. of the block is defined by \cs{edef}. This first of all unwraps the
  274. token lists, but it also has an important effect on
  275. \cs{@gen@open/close}. These control sequences contain a lot of
  276. conditionals which, in combination with the \cs{edef} give a really
  277. dynamic definition of generic constructs in \Lollipop.
  278.  
  279. First of all, the opening and closing commands induce a group
  280. so that various quantities can be set locally.
  281. \Ver>
  282. \def\@gen@open{\outer@start@commands 
  283.     \begingroup \inner@start@commands}
  284. \def\@gen@close{\inner@end@commands 
  285.     \endgroup \outer@end@commands}<Rev
  286.  
  287. The outer start commands concern global actions such as backspacing
  288. previous skips, incrementing counters and setting references.
  289. \Ver>
  290. \def\outer@start@commands{%
  291.     \iftext@construct
  292.         \ifleft@embedded@construct
  293.               \nxp\bsp@hack
  294.         \else \nxp\leavehmode \nxp\bvwit{\the\@whitebefore}\fi<Rev
  295. The `embedded construct' tests are only true if the construct
  296. can be embedded in a paragraph. A~rare occurence most of the time.
  297. \Ver>
  298.         % backspace previous white space while it's visible
  299.         \nxp\if@headed\nxp\else
  300.             \ifforced@break@before\@beforepenalty
  301.             \else\nxp\ifnum\lastpenalty=\z@
  302.                          \@beforepenalty\nxp\fi
  303.             \fi
  304.         \nxp\fi<Rev
  305. A subtle point: a preceding heading will have placed \cs{nobreak} 
  306. followed by a skip. It is dangerous to place any sort of penalty
  307. after this because it might induce a page break.
  308.  
  309. Now the counter, title, and stuff connected to that.
  310. \Ver>
  311.     \fi
  312.     \ifhas@counter \nxp\StepCounter:\expandafter\@name\@space
  313.         % This sets the \current@label by default<Rev
  314. Since this is used inside an \cs{edef} we can use some trickery
  315. to get the space token after the argument to \cs{StepCounter}.
  316. \Ver>
  317.         \ifhas@marks \edef\nxp\cs@e
  318.                {\nxp\nxp\nxp\refresh@mark@item
  319.                 {\@name Counter}{\CSname{\@name Counter}}}%
  320.             \nxp\cs@e      
  321.         \fi
  322.         \fi
  323.     \iflabel@defined 
  324.         \global\current@label={\the\@labelcoms}\fi
  325.     \ifhas@title \install@title@code<Rev
  326. This title business is explained in~\ref[imp:install:title].
  327. This piece of code also refreshes the title in the mark structure.
  328. This has to be done after any page break for the benefit
  329. of headers/footers.
  330. \Ver>
  331.     \fi
  332.     \ifhas@marks\nxp\ifnin{\nxp\place@mark}\fi
  333.         %otherwise IniTeX'ing Lollipop will output a page
  334.     \nxp\xx@label\the\extern@toks\penalty\@M
  335.         % also subtle: if this white space would be higher, it would
  336.         % be invisible because of marks et cetera.
  337.         % insert nobreak after marks/writes to prevent page breaks.
  338.     \iftext@construct
  339.         \ifleft@embedded@construct
  340.               \else \nxp\@vwhite{\the\@whitebefore}\fi
  341.     \fi
  342.     }<Rev
  343.  
  344. Inner start commands are concerned with setting local values.
  345. \Ver>
  346. \def\inner@start@commands{%
  347.     \nxp\Open@Group\CSname{\@class}\CSname{\@name}%<Rev
  348. The \cs{Open@Group} call makes it possible to track down groups
  349. that have inadvertendly been left open. Since we now know the
  350. name we can give helpful error msgs.
  351. \Ver>
  352.     \install@stop<Rev
  353. Install the right implicit closing, see~\ref[sec:implicit:close]
  354. and~\ref[imp:implicit:close].
  355. \Ver>
  356.     \ifleft@embedded@construct
  357.     \else \nxp\hold@parskip 
  358.         \nxp\@defaulteverypar
  359.         \ifwhiteleft@defined \advance\leftskip \the\@whiteleft \relax \fi
  360.         \ifwhiteright@defined \advance\rightskip \the\@whiteright \relax \fi
  361.         \nxp\let\nxp\par=\nxp\@par %explain to me again why this is necessary...
  362.         \inside@indent \first@indent
  363.     \fi
  364.     \advance\nest@depth\@ne<Rev
  365. The nest depth is used for determining indentation levels.
  366. \Ver>
  367.     }<Rev
  368.  
  369. End commands set up some conditions, most of which will be tested
  370. by the start of any next construct.
  371. \Ver>
  372. \def\inner@end@commands{%
  373.     \nxp\Close@Group\CSname{\@class}\CSname{\@name}%
  374.     \ifright@embedded@construct \else \nxp\leavehmode \fi
  375.     \@afterpenalty
  376.     \ifright@embedded@construct \else \nxp\@vwhite{\the\@whiteafter}\fi
  377.     }
  378. \def\outer@end@commands{%
  379.     \the\after@toks
  380.     \ifright@embedded@construct 
  381.         \nxp\@headedno \nxp\esp@hack
  382.     \else
  383.         \after@indent \nxp\dono@parskip
  384.     \fi}<Rev
  385.  
  386. \iSection[imp:implicit:close] Implicit closing
  387.  
  388. Constructs with an explicit closing command, lists and text blocks,
  389. can be closed by~\cs{>}, which simply closes the current
  390. construct. A~more drastic version, \cs{>]}, closes all currently
  391. open constructs.
  392. \Ver>
  393. \def\outer@stop@command{\Emessage{Vacuous group closing}}
  394. \let\default@stop@command\outer@stop@command
  395. \def\>{\default@stop@command%[fool the editor
  396.     \ifNextChar]{%
  397.         \ifx\default@stop@command\outer@stop@command
  398.             \xp\take@one
  399.         \else \xp\>\fi}{}}<Rev
  400. The \cs{outer@stop@command} is meant to give an error msg if the
  401. user attempts to close a group while none is open.
  402.  
  403. The current meaning of~\cs{>} is installed in
  404. \cs{inner@start@commands}:
  405. \Ver>
  406. \def\install@stop{\if@implicitclose
  407.         \def\nxp\default@stop@command
  408.                {\CSname{\stop@command}}%
  409.     \else \let\nxp\default@stop@command
  410.               \nxp\outer@stop@command 
  411.     \fi}<Rev
  412.  
  413. By default, constructs can be closed implicitly, but there is an
  414. option \refopt{noimplicitclose} to disable this.
  415. \Ver>
  416. \newif\if@implicitclose
  417. \add@generic@default{\@implicitcloseyes}
  418. \@GenericOption{noimplicitclose}{\@implicitcloseno}<Rev
  419. This option is for instance used in the examples in this manual.
  420. Otherwise closing a construct in the example would also close the
  421. example itself.
  422.  
  423. \ImpNoteStop
  424.